package com.shilin.watchsystem.config;


import com.shilin.watchsystem.interceptor.LoginHandlerInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class SysWebMvcConfigurer implements WebMvcConfigurer {

    @Bean
    LoginHandlerInterceptor loginHandlerInterceptor(){
        return new LoginHandlerInterceptor();
    }



    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //认证拦截器
        registry.addInterceptor(loginHandlerInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/watchsystem/admin/login")
                .excludePathPatterns("/watchsystem/admin/login")
                .excludePathPatterns("/watchsystem/product/page")
                .excludePathPatterns("/watchsystem/product/select")
                .excludePathPatterns("/watchsystem/order/insert")
                .excludePathPatterns("/*.html", "/css/**")
                .excludePathPatterns("/**.jpg")
                .excludePathPatterns("/adminy/**");
    }

}
